<%--
  Created by IntelliJ IDEA.
  User: hanfei
  Date: 18/6/27
  Time: 下午3:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.wuming.caiwu.security.SecurityHander" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>配送规则</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${allServerPath}static/css/bootstrap.min.css">
    <link rel="stylesheet" href="${allServerPath}static/layui/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${allServerPath}static/layui/css/style.css">
    <link rel="stylesheet" href="${allServerPath}static/layui/css/public.css">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->

    <style>
        .tab_zp td span {
            font-weight: bold;
            color: #003399;
        }

        ::-moz-placeholder {
            color: #d4d4d4;
        }

        ::-webkit-input-placeholder {
            color: #d4d4d4;
        }

        :-ms-input-placeholder {
            color: #d4d4d4;
        }

        .pic-content button{
            position: absolute;
            top: 30px;
            left: 30px;
            width: 120px;
            height: 120px;
            background-color: transparent;
        }

    </style>
</head>
<body>
<div style="padding: 15px;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>商品配送基本信息</legend>
    </fieldset>

    <form class="layui-form" action="" id="shipForm">
        <div class="layui-row">
            <div class="layui-col-xs12">
                <div class="layui-form-item">
                    <label class="layui-form-label">规则名</label>

                    <div class="form-group layui-input-block" style="width: 450px;">
                        <input type="text" name="ruleName" placeholder="" autocomplete="off"
                               class="layui-input" style="width: 50%;display: inline-block"
                               value="">
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12">
            <div class="layui-form-item">
                <label class="layui-form-label">物流费(每件)</label>

                <div class="form-group layui-input-inline">
                    <input type="text" name="price" placeholder="" autocomplete="off"
                           class="layui-input" value="">
                </div>
                <span>元</span>
            </div>
            </div>
            <div class="layui-col-xs12">
            <div class="layui-form-item">
                <label class="layui-form-label">包邮金额</label>

                <div class="form-group layui-input-inline">
                    <input type="text" name="freeShipMoney" value="" id="freeShipMoney"
                           autocomplete="off" class="layui-input">
                </div>
                <span>元</span>
            </div>
            </div>
            <div class="layui-col-xs12">
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="form-group layui-input-inline">
                    <select id="status" name="status" lay-filter="status">
                        <option value=""></option>
                        <option value="0">启用</option>
                        <option value="1">禁用</option>
                    </select>
                </div>
            </div>
            </div>
        </div>
        <input type="hidden" name="storeId" value="<%=SecurityHander.getCurrentUserId()%>">
    </form>
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="layui-form-item">
                <button class="layui-btn" type="button" name="btnSave" id="btnSave" lay-filter="category">保存商品配送信息
                </button>
            </div>
        </div>
    </div>

</div>

<script src="${allServerPath}static/layui/layui/layui.js" charset="utf-8"></script>
<script src="${allServerPath}static/js/jquery-2.1.4.min.js" charset="utf-8"></script>
<script src="${allServerPath}static/js/bootstrap.min.js" charset="utf-8"></script>
<script type="text/javascript" src="${allServerPath}static/js/bootstrapValidator.js"></script>
<script type="text/javascript" src="${allServerPath}static/js/common/date-util.js"></script>

<script>
    layui.use(['layer', 'form', 'laydate', 'jquery', 'upload'], function () {
        var form = layui.form
            , layer = layui.layer
            , $ = layui.jquery
            , upload = layui.upload;


        $(document).ready(function(){
           getShipRule();
        });

        function getShipRule(){
            $.ajax({
                type: 'get',
                url: '${allServerPath}web/productship/get.htmls',
                data: {
                    "storeId": $("input[name='storeId']").val()
                },
                dataType: 'JSON',
                success: function (obj) {
                    if (obj.success) {
                        console.log(JSON.stringify(obj));
                        var status = obj.data.status;
                        $("#status").val(status);
                        $("input[name='ruleName']").val(obj.data.ruleName);
                        $("input[name='price']").val(obj.data.price);
                        $("input[name='freeShipMoney']").val(obj.data.freeShipMoney);
                        form.render();
                    }
                }
            });
        }


        $("button[name='btnSave']").click(function () {
                $.ajax({
                    type: 'post',
                    url: '${allServerPath}web/productship/save.htmls',
                    data: $("#shipForm").serialize(),
                    dataType: 'JSON',
                    success: function (data) {
                        if (data.success) {
                            layer.msg("保存成功.");
                        } else {
                            layer.msg(data.message);
                        }
                    },
                    error: function () {
                        layer.msg("保存失败.");
                    }
                });
        });
    });
</script>
</body>
</html>
